package com.beiding.workordersystem.common.standard;

import com.beiding.workordersystem.common.exception.BaseException;
import com.google.common.base.Joiner;

public class E extends BaseException {

    public E(String message) {
        super(message);
    }

    public static void error(Object first, Object... msg) {
        throw new E(first + Joiner.on(" ").join(msg));
    }

    public static void isFalse(boolean condition,Object first, Object... msg) {
        if (condition) {
            error(first,msg);
        }
    }

    public static void isTrue(boolean condition,Object first,  Object... msg) {
        if (!condition) {
            error(first,msg);
        }
    }

    public static void isNull(Object object,Object first,  Object... msg) {
        isTrue(object == null, first, msg);
    }

    public static void notNull(Object object,Object first,  Object... msg) {
        isTrue(object != null, first, msg);
    }

    public static void noEmpty(Object object, Object first, Object... msg) {
        notNull(object, first, msg);
        if ("".equals(object)) {
            error(first, msg);
        }
    }

}
